<?php
/**
 * Created by PhpStorm.
 * User: u
 * Date: 2019/4/12
 * Time: 17:05
 */

namespace common\sources\write\taskcommod;

use Yii;
use common\models\craftsman\TaskCommod;

class TaskCommodAccess implements ITaskCommodAccess
{
    public function modifyTaskCommod($data)
    {
        $sql = 'UPDATE ' . TaskCommod::tableName() . ' SET task_answer = :task_answer,surplus_task_num = :surplus_task_num,update_time = :update_time WHERE id = :id ';
        return Yii::$app->db->createCommand($sql)
            ->bindValues([
                ':task_answer' => $data['task_answer'],
                ':surplus_task_num' => $data['surplus_task_num'],
                ':update_time' => time(),
                ':id' => $data['id']
            ])->execute();
    }

    public function taskCommodComplete($data)
    {
        $sql = 'UPDATE ' . TaskCommod::tableName() . ' SET task_status = :task_status,update_time = :update_time WHERE id = :id ';
        return Yii::$app->db->createCommand($sql)
            ->bindValues([
                ':task_status' => $data['task_status'],
                ':update_time' => time(),
                ':id' => $data['id']
            ])->execute();
    }
}